#include "physic.h"

Physic::Physic(Vectorf * obj)
{
    objectPosition=obj;

    printf("obj : %f", obj->y());
    velocity = new Vectorf(0.0, 0.0, 0.0);
    delta=0.015;    //  15 milliseconde par rafraichissement de l'image
    floor=0.0;
    signe=1;
}

void Physic::AddAcceleration(Vectorf *vec)
{
    pile.push(vec);
    valGravity=-9.8;
}

void Physic::Do()
{
    Vectorf * accelerationFinale = new Vectorf(0.0, 0.0, 0.0);

    while(pile.size()!=0)
    {
        *accelerationFinale=*accelerationFinale+(*(pile.top()));
        pile.pop();
    }

    Vectorf vitesseA= (*accelerationFinale*delta);

    *velocity=*velocity+vitesseA;
    *objectPosition= *objectPosition+(*velocity*delta);
}
